<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>账号注册-商户注册</title>
    <link rel="stylesheet" type="text/css" href="{{asset('css/home/reset.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{asset('css/home/style.css')}}"/>
    <link rel="stylesheet" href="{{asset('css/home/qy_style.css')}}">
    <link rel="shortcut icon" type="image/x-icon" href='{{asset('image/heeypay/anyun.ico')}}' media="screen" />
    <link rel="stylesheet" type="text/css" href="{{asset('css/heeypay/common.css')}}"  />


    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="{{asset('js/buz/jquery.min.js')}}"></script>
    <script src="{{asset('js/buz/common.js')}}"></script>
    <script src="{{asset('vendor/bootstrap/js/bootstrapValidator.js')}}"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="{{asset('vendor/bootstrap/js/bootstrap.min.js')}}"></script>
</head>
<body>
@include('layouts.home.header', ['active' => 'register', 'hideLogin' => true])
<!--content-->
<div class="content content2" style="padding-top: 0px;display: flex;
    align-items: center;
    justify-content: center;">
    <div class="regisbox">
        <ul class="title">
            <li>1.账号认证</li>
            <li  class="active">2.密码设置</li>
            <li>3.注册完成</li>
            <div class="cur"></div>
        </ul>
        <div class="regis regis2">
            <link href="{{asset('vendor/bootstrap/css/bootstrap.min.css')}}" rel="stylesheet">
            <div class="panel panel-default clearfix">
                <div class="tab">
                    <!--<h3 class="panel-title">-->
                    账号注册
                    <!--</h3>-->
                    <span class="fr"><em class="colorred">*</em>为必填项</span>
                </div>
                <div class="panel panel-default">

                    @if(count($errors) > 0)
                        <div class="alert alert-danger" role="alert">
                            <ul>
                                @foreach($errors->all() as $value)
                                    <li> {{$value}} </li>
                                @endforeach
                            </ul>
                        </div>

                    @else

                        <div class="panel-heading">
                            <!--<h3 class="panel-title">-->
                            账号注册
                            <!--</h3>-->
                            <span class="fr"><em class="colorred">*</em>为必填项</span>
                        </div>
                        <div class="panel-body">
                            <form class="form-horizontal" role="form" id="register">
                                <input type="hidden" name="token" value="{{$credentials['token']}}" id="Rtoken"/>
                                <div class="form-group">
                                    <label for="firstname" class="col-xs-4 col-sm-2 control-label"><em class="colorred">*</em>登录密码：</label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <input type="password" class="form-control" name="password">
                                    </div>
                                    <span class="remend">(登录平台时使用)</span>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-xs-4 col-sm-2 control-label"><em class="colorred">*</em>确认密码：</label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <input type="password" class="form-control" name="confirmpwd">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="firstname" class="col-xs-4 col-sm-2 control-label"><em class="colorred">*</em>交易密码：</label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <input type="password" class="form-control" name="trade_pwd">
                                    </div>
                                    <div class="col-xs-10 col-sm-10 col-md-8 col-lg-8">
                                        <span class="remend">(当您在账户信息变更、关键业务操作时都会进行身份确认，从而提高您的账户安全性)</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-xs-4 col-sm-2 control-label"><em class="colorred">*</em>确认交易码：</label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <input type="password" class="form-control" name="confirmtrade_pwd">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="lastname" class="col-xs-4 col-sm-2 control-label"><em class="colorred">*</em>联系人姓名：</label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <input type="text" class="form-control" name="contact">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-xs-4 col-sm-2 control-label"><em class="colorred">*</em>QQ：</label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <input type="text" class="form-control" name="qq">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="firstname" class="col-sm-2 control-label"></label>
                                    <div class="col-xs-10 col-sm-5 col-md-4 col-lg-4">
                                        <button type="button" class="btn btn-primary" id="forgetNext">下一步</button>
                                    </div>
                                </div>
                            </form>

                        </div>
                </div>
                @endif()
            </div>
        </div>
    </div>
</div>
{{--警告弹窗--}}
<div class="modal fade in"  tabindex="-1" role="dialog" id="errorModel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h4 class="text-center"></h4>
            </div>
            <div class="modal-footer text-xs-center">
                <button type="button" class="btn btn-danger" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    $('#register').bootstrapValidator({
        message: '这个值没有被验证',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            password: {
                message: '密码不能为空',
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 20,
                        message: '密码只能由6-20位字母、数字和下划线组成'
                    },
                    regexp: {
                        regexp: /^[0-9a-zA-Z_]{1,}$/,
                        message: '密码只能由6-20位字母、数字和下划线组成'
                    }
                }
            },
            confirmpwd: {
                message: '密码重复还没有验证',
                validators: {
                    notEmpty: {
                        message: '密码重复不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 16,
                        message: '密码长度在6到16之间'
                    },
                    identical: {
                        field: 'newpwd',
                        message: '两次密码不同请重新输入'
                    }
                }
            },
            trade_pwd: {
                message: '安全码不能为空',
                validators: {
                    notEmpty: {
                        message: '安全码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 6,
                        message: '验证码长度为6位'
                    },
                    different: {
                        field: 'newpwd',
                        message: '安全码不能和密码一致'
                    }
                }
            },
            confirmtrade_pwd: {
                message: '安全码重复还未验证',
                validators: {
                    notEmpty: {
                        message: '安全码重复不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 6,
                        message: '验证码长度为6位'
                    },
                    identical: {
                        field: 'safecode',
                        message: '两次安全码不同请重新输入'
                    }
                }
            },
            contact: {
                message: '联系人姓名不能为空',
                validators: {
                    notEmpty: {
                        message: '联系人姓名不能为空'
                    },
                }
            },
            qq: {
                message: 'QQ不能为空',
                validators: {
                    notEmpty: {
                        message: 'QQ不能为空'
                    },
                }
            }


        }
    }).on('success.form.bv', function (e) {
        // Prevent form submission
        e.preventDefault();
        // Get the form instance
        var $form = $(e.target);
        // Get the BootstrapValidator instance
        var bv = $form.data('bootstrapValidator');
        console.log($form.serialize())
        $.post("/api/auth/doregister", $form.serialize(), function (data) {
            console.log(data)
            if (data.code == 0){
                window.location.href = '/register_three';
            }else if(data.code == 40003){
                var str = "";
                var obj = data.message;
                $.each(obj,function(i){
                    var childObj = obj[i];
                    for(var j=0;j<childObj.length;j++){
                        str += childObj[j]+"<br/>";
                    }
                });
                showMsg(str);
            }else{
                showMsg("data.message");
            }
        });
    });

    /*下一步*/
    $("#forgetNext").click(function(e){
        $('#register').bootstrapValidator('validate');
    });
</script>


</html>
